package com.cn.configuration;

import com.cn.service.DataSourceService;

/**
 * @author chenming
 * @version 1.0
 * Date 2022/9/23 16:33
 * description 定位服务器
 */
public class ServiceLocator {

    private static InitialCache cache = new InitialCache();

    public static DataSourceService getService(String serviceName)
    {
        DataSourceService service = cache.getServices(serviceName);
        if (service != null)
            return service;
        InitialContext context = new InitialContext();
        DataSourceService dataSourceService = (DataSourceService)context.lookup(serviceName);
        cache.addService(dataSourceService);
        return dataSourceService;
    }

}
